{extend name="public:base"}
{block name='css'}
<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
{/block}
{block name="js"}
<script src="__PUBLIC__/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/js/plugins/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/plugins/validate/messages_zh.min.js"></script>
<script type="text/javascript">
    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });

    $("#commentForm").validate({
        rules: {
            locks: "required",
            reward_count: "required",
            per_coin: "required",
            max_coin: "required",
            app_count: "required",
            withdraw_count: "required",
            min_withdraw: "required"
        },
        messages: {
            locks: $('input[name=locks]').attr('placeholder'),
            reward_count: $('input[name=reward_count]').attr('placeholder'),
            per_coin: $('input[name=per_coin]').attr('placeholder'),
            max_coin: $('input[name=max_coin]').attr('placeholder'),
            app_count: $('input[name=app_count]').attr('placeholder'),
            withdraw_count: $('input[name=withdraw_count]').attr('placeholder'),
            min_withdraw: $('input[name=min_withdraw]').attr('placeholder')
        },
//            showErrors: function (errorMap, errorList) {
//                var msg = "";
//                $.each(errorList, function (i, v) {
//                    layer.msg(v.message);
//                    return false;
//                });
//            },
        submitHandler: function(form){
            if ($(form).hasClass('ed')) {
                return false;
            }

            $(form).addClass('ed');
            var obj = showMyLoading();
            $.post("{:url('', ['id'=>$data['id']])}", $(form).serialize(), function(data){
                hideMyLoading(obj);
                layer.msg(data.info);
                $(form).removeClass('ed');
                if (data.status == 'y') {
                    setTimeout(function(){
                        window.location.reload();
                    }, 1500);
                }
            }, 'json');
        }
    });

    function blurIt(self) {
        var val = $(self).val();
        if (val) {
            val = parseFloat(val);
            if (val < 0 || isNaN(val)) {
                val = '';
            }

            $(self).val(val);
        }
    }
</script>
{/block}
{block name='body'}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>系统参数配置</h5>
                    </div>
                    <div class="ibox-content">
                        <form method="post" class="form-horizontal" id="commentForm">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">网站名称</label>
                                <div class="col-sm-10">
                                    <input type="text" maxlength="20" name="website_title" value="{$data.content.website_title|default=''}" placeholder="请输入网站名称" class="form-control">
                                </div>
                            </div>

							<div class="form-group">
                                <label class="col-sm-2 control-label">登录超时时间</label>
                                <div class="col-sm-10">
                                    <input type="number" min="0" max="9999999" name="locks" value="{$data.content.locks|default=''}" placeholder="请输入登录超时时间" onblur="blurIt(this)" class="form-control">
									<span class="help-block m-b-none">登录超时时间，单位（分钟），后台账户登录后{$data.content.locks|default='多少'}分钟内没有点击任何操作则登录超时，需要重新输入密码解锁！</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">最小提现金额</label>
                                <div class="col-sm-10">
                                    <input type="number" min="0" max="9999999" step="0.01" name="min_withdraw_amount" value="{$data.content.min_withdraw_amount|default=''}" placeholder="请输入最小提现金额" onblur="blurIt(this)" class="form-control">
                                    <span class="help-block m-b-none">用户申请提现的最小金额是{$data.content.min_withdraw_amount|default='多少'}元</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">自动收货</label>
                                <div class="col-sm-10">
                                    <input type="number" min="1" max="666" name="auto_days_order_confirm" value="{$data.content.auto_days_order_confirm|default=''}" placeholder="请输入多少天后系统自动收货" onblur="blurIt(this)" class="form-control">
                                    <span class="help-block m-b-none">待收货状态下，用户{$data.content.auto_days_order_confirm|default='多少'}天内没有确认收货，系统自动收货</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">自动关闭订单</label>
                                <div class="col-sm-10">
                                    <input type="number" min="1" max="666" name="auto_days_order_close" value="{$data.content.auto_days_order_close|default=''}" placeholder="请输入多少天后系统自动关闭订单" onblur="blurIt(this)" class="form-control">
                                    <span class="help-block m-b-none">待付款状态下，用户{$data.content.auto_days_order_close|default='多少'}天内没有付款，系统自动关闭订单</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">满额分销</label>
                                <div class="col-sm-10">
                                    <input type="number" step="0.01" min="0" max="9999999" name="full_amount" value="{$data.content.full_amount|default=''}" placeholder="请输入单笔订单满多少金额可以参与分销" onblur="blurIt(this)" class="form-control">
									<span class="help-block m-b-none">单笔订单满{$data.content.full_amount|default='多少'}元可以参与分销</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">起送金额</label>
                                <div class="col-sm-10">
                                    <input type="number" step="0.01" min="0" max="9999999" name="min_amount" value="{$data.content.min_amount|default=''}" placeholder="请输入单笔订单满多少元才能下单" onblur="blurIt(this)" class="form-control">
                                    <span class="help-block m-b-none">单笔订单满{$data.content.min_amount|default='多少'}元才能下单</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">配送范围</label>
                                <div class="col-sm-10">
                                    <input type="number" step="0.01" min="0" max="9999999" name="min_km" value="{$data.content.min_km|default=''}" placeholder="请输入收货地址在多少公里内才能下单" onblur="blurIt(this)" class="form-control">
                                    <span class="help-block m-b-none">收货地址在{$data.content.min_km|default='多少'}公里内才能下单</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分销提成比例</label>
                                <div class="col-sm-10">
                                    <div>
                                        一级分销：<input type="number" step="0.01" min="0" max="9999999" name="percentage1" value="{$data.content.percentage1|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">%
                                    </div>
                                    <div>
                                        二级分销：<input type="number" step="0.01" min="0" max="9999999" name="percentage2" value="{$data.content.percentage2|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">%
                                    </div>
                                    <div>
                                        三级分销：<input type="number" step="0.01" min="0" max="9999999" name="percentage3" value="{$data.content.percentage3|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">%
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分级奖励</label>
                                <div class="col-sm-10">
                                    <div>
                                        主管：每月日平均<input type="number" step="0.01" min="0" max="9999999" name="zg_amount" value="{$data.content.zg_amount|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">元 奖励<input type="number" step="0.01" min="0" max="9999999" name="zg_percentage" value="{$data.content.zg_percentage|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">%
                                    </div>
                                    <div>
                                        经理：下级存在<input type="number" step="0.01" min="0" max="9999999" name="zg_num" value="{$data.content.zg_num|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">个主管 奖励<input type="number" step="0.01" min="0" max="9999999" name="jl_percentage" value="{$data.content.jl_percentage|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">%
                                    </div>
                                    <div>
                                        总监：下级存在<input type="number" step="0.01" min="0" max="9999999" name="jl_num" value="{$data.content.jl_num|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">个经理 奖励<input type="number" step="0.01" min="0" max="9999999" name="zj_percentage" value="{$data.content.zj_percentage|default=''}" style="width:150px;display: inline-block;" placeholder="0" onblur="blurIt(this)" class="form-control">%
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">积分比例</label>
                                <div class="col-sm-10">
                                    <input type="number" min="0" max="9999999" step="0.01" name="integral_rate" value="{$data.content.integral_rate|default=''}" placeholder="请输入人名币与积分兑换比例" onblur="blurIt(this)" class="form-control">
                                    <span class="help-block m-b-none">人名币与积分兑换比例  1元 = {$data.content.integral_rate|default='多少'}积分</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">积分转结时间</label>
                                <div class="col-sm-10">
                                    <input type="number" min="0" max="365" name="auto_days" value="{$data.content.auto_days|default=''}" placeholder="请输入积分转结时间(天)" onblur="blurIt(this)" class="form-control">
                                    <span class="help-block m-b-none">积分{$data.content.auto_days|default='多少'}天后自动结转为余额</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">品牌</label>
                                <div class="col-sm-10">
                                    <input type="text"  name="band" value="{$data.content.band|default=''}" placeholder="请输入品牌" class="form-control">
                                    <span class="help-block m-b-none">配件品牌,多个品牌用<font style='color:red;'>/</font>隔开</span>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">保存内容</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
{/block}
